%   PATH=/usr/local/texlive/2011/bin/x86_64-linux:$PATH 

% Uncomment following four lines to compile standalone
%\documentclass[a4paper, 12pt] {book}
%\usepackage{amssymb,amsmath,tabularx}
%\numberwithin{equation}{section}
%\begin{document}


% Uncomment 2 lines below to see how table of contents work, need to compile twice.
%\setcounter{tocdepth}{1}
%\tableofcontents

%\chapter{example}
\section{Assymetric Exponential Power Distribution, Review and MLE derivation}
The assymetric exponenetial power distribution (AEPD) accommodates fat-tailedness and
skewness while permitting maximum likelihood estimation of all parameters.  
AEPD distributions are valuable in financial modeling of various instruments. 
There have been various AEPD introduced in literature, this section will focus on one introduced by
Ayebo and Kozubowski (2003), a four parameter version.
\newline
\newline
The density (pdf) of the AEPD distribution is:
\begin{equation} \label{eq:AEPDpdf}
f_{AEPD}(x|\beta) = \left\{
\begin{array} {c l}
  \frac{\alpha}{\sigma\Gamma(\frac{1}{\alpha})}
  \frac{\kappa}{1+\kappa^2}
  exp(-\frac{\kappa^\alpha}{\sigma^\alpha}(x-\theta)^\alpha) & x > \theta \\
  \frac{\alpha}{\sigma\Gamma(\frac{1}{\alpha})}
  \frac{\kappa}{1+\kappa^2}
  exp(-\frac{1}{\kappa^\alpha\sigma^\alpha}(\theta-x)^\alpha) & x \leq \theta 
\end{array}
\right.
\end{equation}
where $\beta =(\alpha, \theta, \sigma, \kappa)^T$ is the parameter vector and $\alpha > 0, \theta \in R, \sigma > 0, \kappa > 0$
are the conditions on the parmeters. $\alpha$ is the tail paramter, $\theta$ represents location, $\sigma$ represents scale, and
$\kappa$ is the skewness parameter.  More recent versions of AEPD distributions have featured different scaling parameters for the
left and right tails. We will focus on the density from \eqref{eq:AEPDpdf} for this thesis, but the acceleration results here are easily 
extended to these newer versions of the AEPD.

Suppose there is a sample $x_1, x_2, \cdots, x_n$ of n i.i.d. observations drawn from the AEPD.
Let $x_{(1)}, x_{(2)}, \cdots , x_{(n)}$ be the sorted version of $x_1, x_2, \cdots, x_n$ such that 
$x_{(1)} \leq x_{(2)} \leq \cdots \leq x_{(n)}$. The likelihood function of the AEPD is:
\begin{equation} \label{eq:AEPDlikelihood}
\begin{split}
\emph{L}(\beta|x_1, x_2,\cdots , x_3) &= \prod_{i=1}^{n}f(x_i|\beta) \\
&=C^n \cdot 
\prod_{i=1}^{r} exp(-\frac{\kappa^\alpha}{\sigma^\alpha}(x_{(i)}-\theta)^\alpha) \cdot
\prod_{i=r+1}^{n} exp(-\frac{1}{\kappa^\alpha\sigma^\alpha}(\theta-x_{(i)})^\alpha)
\end{split}
\end{equation}
where $C =   \frac{\alpha}{\sigma\Gamma(\frac{1}{\alpha})}
  \frac{\kappa}{1+\kappa^2}$
\newline
\newline
The log-likelihood $\emph{L}^*$ of the AEPD is:
\begin{equation} \label{eq:AEPDlogLike}
\emph{L}^* = n(\log\frac{\alpha}{\Gamma(\frac{1}{\alpha})}
+\log\frac{\kappa}{1+\kappa^2} - \log\sigma)
-\frac{\kappa^\alpha}{\sigma^\alpha}X_{\theta}^+
-\frac{X_{\theta}^-}{\kappa^\alpha\sigma^\alpha}
\end{equation}
where 
$X_{\theta}^+ = \sum_{i=1}^{r}(x_{(i)}-\theta)^\alpha
X_{\theta}^- = \sum_{i=r+1}^{n}(\theta-x_{(i)})^\alpha$ 
Calculating the MLE for $\hat{\alpha},\hat{\theta}, \hat{\sigma}, \hat{\kappa}$ begins with finding $\hat{\sigma}$ when
all other parameters are known, in this case we need to maximize the following function:
\begin{equation} \label{eq:maxSigma}
Q(\sigma) = -\log\sigma
-\frac{\kappa^\alpha}{\sigma^\alpha}X_{\theta}^+
-\frac{X_{\theta}^-}{\kappa^\alpha\sigma^\alpha}
\end{equation}
Taking the derivative of \eqref{eq:maxSigma}:
\begin{equation}
\frac{\partial Q(\sigma)}{\partial\sigma} = \frac{1}{\sigma}-\sigma^{-\alpha-1}\alpha
(\kappa^\alpha X_{\theta}^+\frac{X_{\theta}^-}{\kappa^\alpha}) = 0
\end{equation}
then
\begin{equation} \label{eq:MLEsigma}
\hat{\sigma} = \alpha(\kappa^\alpha X_{\theta}^+\frac{X_{\theta}^-}{\kappa^\alpha})^{\frac{1}{\alpha}}
\end{equation} 
The case of unknown $\sigma, \kappa$, In this case, substituting \eqref{eq:MLEsigma} into \eqref{EQ:AEPDlogLike} means maximizing:
\begin{equation} \label{eq:sigmakappaLikelihood}
Q(\sigma(\kappa),\kappa) = \log(\frac{\kappa}{1+\kappa^2}) - \frac{\log\alpha}{\alpha}-
\frac{1}{\alpha}
(\log(\kappa^\alpha X_{\theta}^++\kappa^{-\alpha}X_{\theta}^-)
- \frac{1}{\alpha}
\end{equation}
Solving for $\hat{\kappa}$:
\begin{equation} \label{eq:MLEkappa}
\hat{\kappa} = 
\left[
\frac{X_{\theta}^-}{X_{\theta}^+}
\right]
^{\frac{1}{2(\alpha+1)}}
\end{equation}
Using \eqref{eq:MLEkappa} and \eqref{eq:MLEsigma} to solve for $\hat{\sigma}$:
\begin{equation} \label{eq:MLEsigma2}
\hat{\sigma} =
\big[
\alpha(X_{\theta}^+ X_{\theta}^-)^{\frac{\alpha}{2(\alpha+1)}} 
\big(
(X_{\theta}^+)^{\frac{1}{\alpha+1}} +
(X_{\theta}^-)^{\frac{1}{\alpha+1}}
\big)
\big]
^{\frac{1}{\alpha}}
\end{equation}
The case of unknown $\sigma, \kappa, \alpha, \theta$: In this case the object is to maximize the log-likelihood in \eqref{eq:AEPDlogLike}, 
substituting \eqref{eq:MLEkappa} and \eqref{eq:MLEsigma2} for $\kappa$ and $\sigma$ in \eqref{eq:AEPDlogLike}, respectively.  The values of 
$\alpha$ are a parameter that the modeler can choose a range for, (typically starting around $1 < \alpha < 2$). 
The values of $\theta$ are noted to be the exact values of the observations 
$x_1, x_2, \cdots, x_n$.  The method of finding maximum likelihood is to find the maximum of \eqref{eq:AEPDlogLike} over the ranges of 
$\alpha, \theta$, then the values of $\alpha$, and $\theta$ associated with the maximum of \eqref{eq:AEPDlogLike} will be the the maximum likelihood estimators
$\hat{\alpha}$ and $\hat{\theta}$.
 
%\end{document}